This example reads data from the FastCCD and corrects and rotates the images. Included are some example of widgets to interact with the data
Load the databroker moudle, csxtools and various other
dependencies
import numpy as np
from databroker import DataBroker, get_table
from csxtools.utils import get_fastccd_images
from csxtools.ipynb import image_stack_to_movie, show_image_stack
%matplotlib inline
from matplotlib import pyplot as plt
Load the headers without the images (using fill=False)
bgnd
| descriptors | [{'_name': 'EventDescriptor', 'data_keys': {'delta': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif-Ax:Del}Mtr.RBV', 'shape': []}, 'saz': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif-Ax:Z}Mtr.RBV', 'shape': []}, 'epu2_gap': {'dtype': 'number', 'source': 'PV:XF:23ID-ID{EPU:2-Ax:Gap}Pos-I', 'shape': []}, 'temp_a': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{TCtrl:1-Chan:A}T-I', 'shape': []}, 'npbz': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif:Lens-Ax:BtmZ}Mtr.RBV', 'shape': []}, 'slt2_xg': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:2-Ax:XGap}Mtr.RBV', 'shape': []}, 'npbx': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif:Lens-Ax:BtmX}Mtr.RBV', 'shape': []}, 'fccd_stats_total1': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{FCCD}Stats1:Total_RBV', 'shape': []}, 'nptx': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif:Lens-Ax:TopX}Mtr.RBV', 'shape': []}, 'fccd_stats_total3': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{FCCD}Stats3:Total_RBV', 'shape': []}, 'sx': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif-Ax:X}Mtr.RBV', 'shape': []}, 'sclr_time': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Sclr:1}.T', 'shape': []}, 'slt1_xc': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:1-Ax:XCtr}Mtr.RBV', 'shape': []}, 'fccd_stats_total4': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{FCCD}Stats4:Total_RBV', 'shape': []}, 'gamma': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif-Ax:Gam}Mtr.RBV', 'shape': []}, 'epu2_phase': {'dtype': 'number', 'source': 'PV:XF:23ID-ID{EPU:2-Ax:Phase}Pos-I', 'shape': []}, 'sclr_chan3': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Sclr:1}.S3', 'shape': []}, 'fccd_stats_total5': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{FCCD}Stats5:Total_RBV', 'shape': []}, 'eta': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Diag:1-Ax:Eta}Mtr.RBV', 'shape': []}, 'fccd_stats_total2': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{FCCD}Stats2:Total_RBV', 'shape': []}, 'npty': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif:Lens-Ax:TopY}Mtr.RBV', 'shape': []}, 'slt2_yg': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:2-Ax:YGap}Mtr.RBV', 'shape': []}, 'slt3_y': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:3-Ax:Y}Mtr.RBV', 'shape': []}, 'fccd_acquire_time': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{FCCD}cam1:AcquireTime_RBV', 'shape': []}, 'epu1_gap': {'dtype': 'number', 'source': 'PV:XF:23ID-ID{EPU:1-Ax:Gap}Pos-I', 'shape': []}, 'temp_b': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{TCtrl:1-Chan:B}T-I', 'shape': []}, 'npby': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif:Lens-Ax:BtmY}Mtr.RBV', 'shape': []}, 'fccd_acquire_period': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{FCCD}cam1:AcquirePeriod_RBV', 'shape': []}, 'sclr_chan6': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Sclr:1}.S6', 'shape': []}, 'sclr_chan1': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Sclr:1}.S1', 'shape': []}, 'sz': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif-Ax:SZ}Pos-RB', 'shape': []}, 'epu1_phase': {'dtype': 'number', 'source': 'PV:XF:23ID-ID{EPU:1-Ax:Phase}Pos-I', 'shape': []}, 'sclr_chan5': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Sclr:1}.S5', 'shape': []}, 'sclr_chan8': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Sclr:1}.S8', 'shape': []}, 'slt1_yc': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:1-Ax:YCtr}Mtr.RBV', 'shape': []}, 'sclr_chan2': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Sclr:1}.S2', 'shape': []}, 'slt3_x': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:3-Ax:X}Mtr.RBV', 'shape': []}, 'sy': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif-Ax:SY}Pos-RB', 'shape': []}, 'ring_curr': {'dtype': 'number', 'source': 'PV:XF:23ID-SR{}I-I', 'shape': []}, 'fccd_image_lightfield': {'dtype': 'array', 'external': 'FILESTORE:', 'source': 'PV:XF:23ID1-ES{FCCD}', 'shape': [1200, 960, 960]}, 'pgm_energy': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Mono}Enrgy-I', 'shape': []}, 'nptz': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif:Lens-Ax:TopZ}Mtr.RBV', 'shape': []}, 'sclr_chan7': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Sclr:1}.S7', 'shape': []}, 'slt1_xg': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:1-Ax:XGap}Mtr.RBV', 'shape': []}, 'theta': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif-Ax:Th}Mtr.RBV', 'shape': []}, 'sclr_chan4': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Sclr:1}.S4', 'shape': []}, 'slt2_xc': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:2-Ax:XCtr}Mtr.RBV', 'shape': []}, 'slt2_yc': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:2-Ax:YCtr}Mtr.RBV', 'shape': []}, 'slt1_yg': {'dtype': 'number', 'source': 'PV:XF:23ID1-OP{Slt:1-Ax:YGap}Mtr.RBV', 'shape': []}, 'say': {'dtype': 'number', 'source': 'PV:XF:23ID1-ES{Dif-Ax:Y}Mtr.RBV', 'shape': []}}, 'time': 1445472638.1676164, 'run_start': 'ce5042b7-00ae-49ca-9b11-b10c5661aaaa', 'uid': '29645582-4748-41e5-bd9b-95c22c122446'}] | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| start |
|
||||||||||||||||||||||||||||
| stop |
|
bgnd = DataBroker['ce5042b7-00ae-49ca-9b11-b10c5661aaaa'] #[52440]
print(bgnd)
get_table(bgnd, fill=False)
header
======
EventDescriptor
---------------
+-----------------------+--------+------------+------------------+--------------------------------------------+
| data keys | dtype | external | shape | source |
+-----------------------+--------+------------+------------------+--------------------------------------------+
| delta | number | | [] | PV:XF:23ID1-ES{Dif-Ax:Del}Mtr.RBV |
| epu1_gap | number | | [] | PV:XF:23ID-ID{EPU:1-Ax:Gap}Pos-I |
| epu1_phase | number | | [] | PV:XF:23ID-ID{EPU:1-Ax:Phase}Pos-I |
| epu2_gap | number | | [] | PV:XF:23ID-ID{EPU:2-Ax:Gap}Pos-I |
| epu2_phase | number | | [] | PV:XF:23ID-ID{EPU:2-Ax:Phase}Pos-I |
| eta | number | | [] | PV:XF:23ID1-ES{Diag:1-Ax:Eta}Mtr.RBV |
| fccd_acquire_period | number | | [] | PV:XF:23ID1-ES{FCCD}cam1:AcquirePeriod_RBV |
| fccd_acquire_time | number | | [] | PV:XF:23ID1-ES{FCCD}cam1:AcquireTime_RBV |
| fccd_image_lightfield | array | FILESTORE: | [1200, 960, 960] | PV:XF:23ID1-ES{FCCD} |
| fccd_stats_total1 | number | | [] | PV:XF:23ID1-ES{FCCD}Stats1:Total_RBV |
| fccd_stats_total2 | number | | [] | PV:XF:23ID1-ES{FCCD}Stats2:Total_RBV |
| fccd_stats_total3 | number | | [] | PV:XF:23ID1-ES{FCCD}Stats3:Total_RBV |
| fccd_stats_total4 | number | | [] | PV:XF:23ID1-ES{FCCD}Stats4:Total_RBV |
| fccd_stats_total5 | number | | [] | PV:XF:23ID1-ES{FCCD}Stats5:Total_RBV |
| gamma | number | | [] | PV:XF:23ID1-ES{Dif-Ax:Gam}Mtr.RBV |
| npbx | number | | [] | PV:XF:23ID1-ES{Dif:Lens-Ax:BtmX}Mtr.RBV |
| npby | number | | [] | PV:XF:23ID1-ES{Dif:Lens-Ax:BtmY}Mtr.RBV |
| npbz | number | | [] | PV:XF:23ID1-ES{Dif:Lens-Ax:BtmZ}Mtr.RBV |
| nptx | number | | [] | PV:XF:23ID1-ES{Dif:Lens-Ax:TopX}Mtr.RBV |
| npty | number | | [] | PV:XF:23ID1-ES{Dif:Lens-Ax:TopY}Mtr.RBV |
| nptz | number | | [] | PV:XF:23ID1-ES{Dif:Lens-Ax:TopZ}Mtr.RBV |
| pgm_energy | number | | [] | PV:XF:23ID1-OP{Mono}Enrgy-I |
| ring_curr | number | | [] | PV:XF:23ID-SR{}I-I |
| say | number | | [] | PV:XF:23ID1-ES{Dif-Ax:Y}Mtr.RBV |
| saz | number | | [] | PV:XF:23ID1-ES{Dif-Ax:Z}Mtr.RBV |
| sclr_chan1 | number | | [] | PV:XF:23ID1-ES{Sclr:1}.S1 |
| sclr_chan2 | number | | [] | PV:XF:23ID1-ES{Sclr:1}.S2 |
| sclr_chan3 | number | | [] | PV:XF:23ID1-ES{Sclr:1}.S3 |
| sclr_chan4 | number | | [] | PV:XF:23ID1-ES{Sclr:1}.S4 |
| sclr_chan5 | number | | [] | PV:XF:23ID1-ES{Sclr:1}.S5 |
| sclr_chan6 | number | | [] | PV:XF:23ID1-ES{Sclr:1}.S6 |
| sclr_chan7 | number | | [] | PV:XF:23ID1-ES{Sclr:1}.S7 |
| sclr_chan8 | number | | [] | PV:XF:23ID1-ES{Sclr:1}.S8 |
| sclr_time | number | | [] | PV:XF:23ID1-ES{Sclr:1}.T |
| slt1_xc | number | | [] | PV:XF:23ID1-OP{Slt:1-Ax:XCtr}Mtr.RBV |
| slt1_xg | number | | [] | PV:XF:23ID1-OP{Slt:1-Ax:XGap}Mtr.RBV |
| slt1_yc | number | | [] | PV:XF:23ID1-OP{Slt:1-Ax:YCtr}Mtr.RBV |
| slt1_yg | number | | [] | PV:XF:23ID1-OP{Slt:1-Ax:YGap}Mtr.RBV |
| slt2_xc | number | | [] | PV:XF:23ID1-OP{Slt:2-Ax:XCtr}Mtr.RBV |
| slt2_xg | number | | [] | PV:XF:23ID1-OP{Slt:2-Ax:XGap}Mtr.RBV |
| slt2_yc | number | | [] | PV:XF:23ID1-OP{Slt:2-Ax:YCtr}Mtr.RBV |
| slt2_yg | number | | [] | PV:XF:23ID1-OP{Slt:2-Ax:YGap}Mtr.RBV |
| slt3_x | number | | [] | PV:XF:23ID1-OP{Slt:3-Ax:X}Mtr.RBV |
| slt3_y | number | | [] | PV:XF:23ID1-OP{Slt:3-Ax:Y}Mtr.RBV |
| sx | number | | [] | PV:XF:23ID1-ES{Dif-Ax:X}Mtr.RBV |
| sy | number | | [] | PV:XF:23ID1-ES{Dif-Ax:SY}Pos-RB |
| sz | number | | [] | PV:XF:23ID1-ES{Dif-Ax:SZ}Pos-RB |
| temp_a | number | | [] | PV:XF:23ID1-ES{TCtrl:1-Chan:A}T-I |
| temp_b | number | | [] | PV:XF:23ID1-ES{TCtrl:1-Chan:B}T-I |
| theta | number | | [] | PV:XF:23ID1-ES{Dif-Ax:Th}Mtr.RBV |
+-----------------------+--------+------------+------------------+--------------------------------------------+
run_start : ce5042b7-00ae-49ca-9b11-b10c5661aaaa
time : 1445472638.1676164
uid : 29645582-4748-41e5-bd9b-95c22c122446
RunStart
--------
beamline_id : CSX
config :
group :
owner : xf23id1
project :
sample :
scan_args :
delay : 0
num : 1
detectors : [EpicsMotor(name='theta', record='XF:23ID1-ES{Dif-Ax:Th}Mtr'), EpicsMotor(name='delta', record='XF:23ID1-ES{Dif-Ax:Del}Mtr'), EpicsMotor(name='gamma', record='XF:23ID1-ES{Dif-Ax:Gam}Mtr'), EpicsMotor(name='sx', record='XF:23ID1-ES{Dif-Ax:X}Mtr'), PVPositioner(name='sy', setpoint='XF:23ID1-ES{Dif-Ax:SY}Pos-SP', readback='XF:23ID1-ES{Dif-Ax:SY}Pos-RB', stop='XF:23ID1-ES{Dif-Cryo}Cmd:Stop-Cmd', stop_val=1, put_complete=True, settle_time=0.05, limits=(0, 0)), PVPositioner(name='sz', setpoint='XF:23ID1-ES{Dif-Ax:SZ}Pos-SP', readback='XF:23ID1-ES{Dif-Ax:SZ}Pos-RB', stop='XF:23ID1-ES{Dif-Cryo}Cmd:Stop-Cmd', stop_val=1, put_complete=True, settle_time=0.05, limits=(0, 0)), EpicsMotor(name='say', record='XF:23ID1-ES{Dif-Ax:Y}Mtr'), EpicsMotor(name='saz', record='XF:23ID1-ES{Dif-Ax:Z}Mtr'), EpicsSignal(name='temp_a', read_pv='XF:23ID1-ES{TCtrl:1-Chan:A}T-I', rw=False, string=False, limits=False, put_complete=False, pv_kw={}, auto_monitor=None), EpicsSignal(name='temp_b', read_pv='XF:23ID1-ES{TCtrl:1-Chan:B}T-I', rw=False, string=False, limits=False, put_complete=False, pv_kw={}, auto_monitor=None), PVPositioner(name='pgm_energy', setpoint='XF:23ID1-OP{Mono}Enrgy-SP', readback='XF:23ID1-OP{Mono}Enrgy-I', stop='XF:23ID1-OP{Mono}Cmd:Stop-Cmd', stop_val=1, put_complete=True, settle_time=0.05, limits=(200, 2200)), PVPositioner(name='epu1_gap', setpoint='XF:23ID-ID{EPU:1-Ax:Gap}Pos-SP', readback='XF:23ID-ID{EPU:1-Ax:Gap}Pos-I', stop='SR:C23-ID:G1A{EPU:1-Ax:Gap}-Mtr.STOP', stop_val=1, put_complete=True, settle_time=0.05, limits=(0, 0)), PVPositioner(name='epu1_phase', setpoint='XF:23ID-ID{EPU:1-Ax:Phase}Pos-SP', readback='XF:23ID-ID{EPU:1-Ax:Phase}Pos-I', stop='SR:C23-ID:G1A{EPU:1-Ax:Phase}-Mtr.STOP', stop_val=1, put_complete=True, settle_time=0.05, limits=(0, 0)), PVPositioner(name='epu2_gap', setpoint='XF:23ID-ID{EPU:2-Ax:Gap}Pos-SP', readback='XF:23ID-ID{EPU:2-Ax:Gap}Pos-I', stop='SR:C23-ID:G1A{EPU:2-Ax:Gap}-Mtr.STOP', stop_val=1, put_complete=True, settle_time=0.05, limits=(0, 0)), PVPositioner(name='epu2_phase', setpoint='XF:23ID-ID{EPU:2-Ax:Phase}Pos-SP', readback='XF:23ID-ID{EPU:2-Ax:Phase}Pos-I', stop='SR:C23-ID:G1A{EPU:2-Ax:Phase}-Mtr.STOP', stop_val=1, put_complete=True, settle_time=0.05, limits=(0, 0)), EpicsMotor(name='eta', record='XF:23ID1-ES{Diag:1-Ax:Eta}Mtr'), EpicsMotor(name='slt1_xc', record='XF:23ID1-OP{Slt:1-Ax:XCtr}Mtr'), EpicsMotor(name='slt1_xg', record='XF:23ID1-OP{Slt:1-Ax:XGap}Mtr'), EpicsMotor(name='slt1_yc', record='XF:23ID1-OP{Slt:1-Ax:YCtr}Mtr'), EpicsMotor(name='slt1_yg', record='XF:23ID1-OP{Slt:1-Ax:YGap}Mtr'), EpicsMotor(name='slt2_xc', record='XF:23ID1-OP{Slt:2-Ax:XCtr}Mtr'), EpicsMotor(name='slt2_xg', record='XF:23ID1-OP{Slt:2-Ax:XGap}Mtr'), EpicsMotor(name='slt2_yc', record='XF:23ID1-OP{Slt:2-Ax:YCtr}Mtr'), EpicsMotor(name='slt2_yg', record='XF:23ID1-OP{Slt:2-Ax:YGap}Mtr'), EpicsMotor(name='slt3_x', record='XF:23ID1-OP{Slt:3-Ax:X}Mtr'), EpicsMotor(name='slt3_y', record='XF:23ID1-OP{Slt:3-Ax:Y}Mtr'), EpicsSignal(name='ring_curr', read_pv='XF:23ID-SR{}I-I', rw=False, string=False, limits=False, put_complete=False, pv_kw={}, auto_monitor=None), EpicsMotor(name='npbx', record='XF:23ID1-ES{Dif:Lens-Ax:BtmX}Mtr'), EpicsMotor(name='npby', record='XF:23ID1-ES{Dif:Lens-Ax:BtmY}Mtr'), EpicsMotor(name='npbz', record='XF:23ID1-ES{Dif:Lens-Ax:BtmZ}Mtr'), EpicsMotor(name='nptx', record='XF:23ID1-ES{Dif:Lens-Ax:TopX}Mtr'), EpicsMotor(name='npty', record='XF:23ID1-ES{Dif:Lens-Ax:TopY}Mtr'), EpicsMotor(name='nptz', record='XF:23ID1-ES{Dif:Lens-Ax:TopZ}Mtr'), EpicsScaler(name='sclr', record='XF:23ID1-ES{Sclr:1}', numchan=8), AreaDetectorFileStoreHDF5(name='fccd', basename='XF:23ID1-ES{FCCD}', stats=[1, 2, 3, 4, 5], shutter=None, shutter_rb=None, shutter_val=None, file_path='/GPFS/xf23id/xf23id1/fccd_data/', ioc_file_path=None)]
scan_id : 52440
scan_type : Count
time : 1445472516.9860468
uid : ce5042b7-00ae-49ca-9b11-b10c5661aaaa
RunStop
-------
exit_status : success
reason :
run_start : ce5042b7-00ae-49ca-9b11-b10c5661aaaa
time : 1445472638.2573586
uid : 2bf2d671-d8a5-4fb9-b592-798db66b98a0
| time | temp_a | saz | epu2_gap | delta | npbz | slt2_xg | npbx | fccd_stats_total1 | temp_b | ... | ring_curr | fccd_image_lightfield | nptz | sclr_chan7 | slt1_xg | theta | slt2_xc | slt2_yc | slt1_yg | say | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2015-10-22 00:10:38.185091-04:00 | 0 | 4.175332 | 31.020917 | 38.999985 | -5.656265 | 10 | -3.380105 | 137150246 | 0 | ... | 150.056366 | 7180b59d-5112-428e-b6a4-9bc8893220b0 | 6.21667 | 0 | 6.9994 | 19.499985 | 1 | -5.0001 | 7.0003 | 3.249713 |
1 rows × 51 columns
data = DataBroker['b2596f8e-d220-4aea-8a55-8ccb17cbdacc'] #[52436]
get_table(data, fill=False)
| time | temp_a | saz | epu2_gap | delta | npbz | slt2_xg | npbx | fccd_stats_total1 | temp_b | ... | ring_curr | fccd_image_lightfield | nptz | sclr_chan7 | slt1_xg | theta | slt2_xc | slt2_yc | slt1_yg | say | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2015-10-21 23:59:54.531477-04:00 | 0 | 4.175332 | 31.020912 | 38.999985 | -5.65627 | 10 | -3.38011 | 137233260 | 0 | ... | 150.018917 | 20eed5d8-05e2-4b0e-bd3c-5edae7b15878 | 6.216685 | 0 | 6.9994 | 19.499985 | 1 | -5.0001 | 7.0003 | 3.249713 |
1 rows × 51 columns
Now correct the CCD images, using only a single background image.
In the future this should be taken from the metadata associated with the data, or from the darkfield entry
images = get_fastccd_images(data, (bgnd, None, None))
Thanks ipywidgets!
show_image_stack(images, (-100, 100))
This produces an HTML5 movie which can be viewed in most browsers
image_stack_to_movie(images, frames=100, figsize=(12, 10), vmin=-20, vmax=20)